import { Injectable } from '@nestjs/common';
import { DockerImageInfo, ContainerInfo } from './types/docker';
import { DockerTool } from './dockerApiHander';

@Injectable()
export class AppService {
  private dockerTool: DockerTool;

  getHello(): string {
    return 'Hello World!';
  }

  async getDockerImages(): Promise<DockerImageInfo[]> {
    console.log('Fetching Docker images...');
    return this.dockerTool.listImages();
  }

  async getRunningContainers(): Promise<ContainerInfo[]> {
    console.log('Fetching running Docker containers...');
    return this.dockerTool.listRunningContainers();
  }

  async deleteImage(imageIdOrName: string): Promise<void> {
        console.log(`Deleting Docker image: ${imageIdOrName}...`);
        return this.dockerTool.deleteImage(imageIdOrName);
    }
}
